package com.sky.controller.users;


import cn.mybatis.mp.core.mybatis.mapper.context.Pager;
import com.sky.dto.GetScripsDTO;
import com.sky.result.Result;
import com.sky.service.ScriptsService;
import com.sky.vo.GetScripsVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author majun
 * @package com.sky.controller.admin
 * @date 2025/6/21 12:09
 */

@RestController
@RequestMapping("/user/scripts")
@Slf4j
public class UserScriptsController {

    @Autowired
    private ScriptsService scriptsService;

    /**
     * 分页获取剧本
     *
     * @return 响应结果
     */
    @PostMapping("/page")
    private Result<Pager<GetScripsVO>> getUserScrips(@RequestBody GetScripsDTO getScripsDTO) {

        log.info("分页获取剧本");

        Pager<GetScripsVO> pager = scriptsService.getScrips(getScripsDTO);

        return Result.success(pager);

    }

    /**
     * 根据id获取剧本
     *
     * @return 响应结果
     */
    @GetMapping("/getUserScriptsById/{id}")
    private Result<GetScripsVO> getUserScriptsById(@PathVariable Long id) {

        log.info("获取用户剧本");

        GetScripsVO getScripsVO = scriptsService.getScriptsByIdVO(id);

        return Result.success(getScripsVO);

    }

}
